package com.shangrila.web.common;

import java.util.Map;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * @author kalman03
 */
public class AuthenticationInterceptor implements Interceptor {

	private static final long serialVersionUID = -5825193034647320950L;

	@Override
	public void destroy() {
	}

	@Override
	public void init() {
		
	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		Map<String,Object> session = invocation.getInvocationContext().getSession();
		if (session.get(SessionKeeper.LOGIN_USER) == null) {
			return Action.LOGIN;
		} else {
			return invocation.invoke();
		}
	}
}
